package com.ctshk.sapp.order.localfun.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.localfun.req.LocalFunProductOrderReq;
import com.ctshk.rpc.order.localfun.dto.*;
import com.ctshk.rpc.order.localfun.req.*;
import com.ctshk.rpc.order.localfun.service.ILocalFunOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 订单 前端控制器
 * </p>
 *
 * @author gzl-wansi001
 * @since 2021-02-24
 */
@Api(value="门票订单", tags="当地玩乐-门票订单")
@RestController
@RequestMapping("/localFun/order")
public class LocalFunOrderController extends BaseController {

    @DubboReference
    private ILocalFunOrderService iLocalFunOrderService;

    @ApiOperation(value = "核对订单", notes = "预订中心-填写订单页-核对订单", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "预订中心当地玩乐-填写订单页-核对订单", operDesc = "预订中心-当地玩乐-填写订单页-核对订单")
    @PostMapping(value = "/checkOrder")
    public Result addOrderInfo(@RequestBody LocalFunAddCheckOrderReq localFunAddCheckOrderReq){
        return iLocalFunOrderService.addOrderInfo(localFunAddCheckOrderReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "预订中心-订单支付（收款）", notes = "预订中心-支付页面-下单", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "预订中心当地玩乐-支付页面-下单", operDesc = "预订中心-当地玩乐-支付页面-下单")
    @PostMapping(value = "/add/order")
    public Result payOrder(@RequestBody PayOrderReq payOrderReq){
        return iLocalFunOrderService.payOrder(payOrderReq,getCurrentUser(getRequest()));
    }


    @ApiOperation(value = "查询额度", notes = "查询额度", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "挂账额度-查询额度", operDesc = "挂账额度-查询额度")
    @PostMapping("/query-quota")
    public Result<QueryQuotaDTO> queryQuota(@RequestBody @Valid QueryQuotaReq req) {
        return iLocalFunOrderService.queryQuota(req);
    }


    @ApiOperation(value = "订单列表", notes = "订单中心列表", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "订单中心当地玩乐列表", operDesc = "订单中心-当地玩乐列表")
    @PostMapping(value = "/list")
    public Result<PageResponse<LocalFunOrderDTO>> list(@RequestBody LocalFunOrderReq localFunOrderReq){
        return Result.success(iLocalFunOrderService.list(localFunOrderReq,getCurrentUser(getRequest())));
    }

    @ApiOperation(value = "订单详情", notes = "订单中心当地玩乐详情", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "订单中心当地玩乐详情", operDesc = "订单中心-当地玩乐详情")
    @PostMapping(value = "/localFunOrderDetail")
    public Result<LocalFunOrderDetailDTO> localFunOrderDetail(@RequestBody LocalFunOrderDetailReq localFunOrderDetailReq){
        return iLocalFunOrderService.localFunOrderDetail(localFunOrderDetailReq);
    }

    @ApiOperation(value = "取消订单（待付款状态）", notes = "取消订单（待付款状态）", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "取消订单（待付款状态）", operDesc = "取消订单（待付款状态）-当地玩乐")
    @PostMapping(value = "/cancel-localFun-order")
    public Result<Long> cancelLocalFunOrder(@RequestBody @Valid LocalFun0rderCancelReq localFun0rderCancelReq){
        return iLocalFunOrderService.cancelLocalFunOrder(localFun0rderCancelReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="待确认、确认成功、确认失败状态取消订单", notes="待确认、确认成功、确认失败状态取消订单", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "取消订单", operDesc = "取消订单(已付款)-当地玩乐")
    @PostMapping("/cancel-refund-order")
    public Result<Long> cancelLocalFunOrderRefund(@RequestBody @Valid LocalFunOrderRefundDetailReq localFun0rderRefundDetailReq) {
        return iLocalFunOrderService.cancelLocalFunOrderRefund(localFun0rderRefundDetailReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="审批通过，订单取消操作", notes="待确认、确认成功、确认失败状态取消订单", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "取消订单", operDesc = "审批取消订单-当地玩乐")
    @PostMapping("/operate-refund-order")
    public Result<Long> refundOperate(@RequestBody @Valid LocalFunOrderCheckReq localFunOrderCheckReq) {
        return iLocalFunOrderService.refundOperate(localFunOrderCheckReq,getCurrentUser(getRequest()));
    }


    @ApiOperation(value="收款获取订单金额", notes="获取收款订单金额", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.OTHER, operTitle = "取消订单", operDesc = "当地玩乐-收款获取订单金额")
    @PostMapping("/get-order-amount")
    public Result<BigDecimal> getOrderAmount(@RequestBody @Valid LocalFunProductOrderReq localFunOrderCheckReq) {
        return iLocalFunOrderService.getOrderAmount(localFunOrderCheckReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="退款获取订单金额", notes="获取退款订单金额", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.OTHER, operTitle = "取消订单", operDesc = "当地玩乐-退款获取订单金额")
    @PostMapping("/get-refund-amount")
    public Result<BigDecimal> getRefundAmount(@RequestBody @Valid LocalFunProductOrderReq localFunOrderCheckReq) {
        return iLocalFunOrderService.getRefundAmount(localFunOrderCheckReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value = "预订中心-填写订单页-积分汇率换港币", notes = "预订中心-填写订单页-积分汇率换港币", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "预订中心当地玩乐-填写订单页-积分汇率换港币", operDesc = "预订中心当地玩乐--填写订单页-积分汇率换港币")
    @GetMapping(value = "/conversionIntegral/{integral}")
    public Result<LocalFunOrderIntegralExchangeDTO> conversionIntegral(@PathVariable Long integral){
        return iLocalFunOrderService.conversionIntegral(integral);
    }

    @ApiOperation(value = "预订中心当地玩乐-支付页面-查询订单金额与时间", notes = "预订中心当地玩乐-支付页面-查询订单金额与时间", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "预订中心当地玩乐-支付页面-查询订单金额与时间", operDesc = "预订中心当地玩乐--支付页面-查询订单金额与时间")
    @GetMapping(value = "/queryOrderInfo/{orderId}")
    public Result<LocalFunOrderPayQueryInfoDTO> queryOrderInfo(@PathVariable Long orderId){
        return iLocalFunOrderService.queryOrderInfo(orderId);
    }

    @ApiOperation(value="确认订单", notes="确认订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "确认订单", operDesc = "当地玩乐-确认订单")
    @PostMapping("/confirm_order")
    public Result<Long> confirmOrder(@RequestBody @Valid LocalFunProductOrderReq scenicProductOrderReq) {
        return iLocalFunOrderService.confirmOrder(scenicProductOrderReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="通知旅客", notes="通知旅客", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.ADD, operTitle = "确认订单", operDesc = "当地玩乐确认订单")
    @PostMapping("/notice")
    public Result notice(@RequestBody @Valid LocalFunOrderNoticeReq localFun0rderNoticeReq) {
        return iLocalFunOrderService.notice(localFun0rderNoticeReq);
    }
}





















